package com.hero.dao;


import cn.lsj.core.factory.SqlSessionFactory;
import cn.lsj.core.factory.SqlSessionFactoryBuilder;
import cn.lsj.openapi.SqlSession;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

/**
 * @className: CustomFrameTest
 * @description: TODO 类描述
 * @author: liangshijie
 * @date: 2023/3/11
 **/
public class CustomFrameTest {

    @Test
    public void test() throws Exception {
        //1.创建SqlSessionFactoryBuilder对象
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        //2.builder对象构建工厂对象
        InputStream inputStream =
                this.getClass().getClassLoader().getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = builder.build(inputStream);
        //3.打开SqlSession会话
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //4.执行查询Sql语句
        List<SysRole> users = sqlSession.selectList("com.hero.dao.SysRoleMapper.findAll");
        //5.循环打印
        for (SysRole u : users) {
            System.out.println(u);
        }
    }

}
